import { request } from '../http'

interface Ilogin {
  username: string
  password: string
}

export function fetchLogin(data: Ilogin) {
  const methodInstance = request.Post<Service.ResponseResult<Api.Login.BackendResponse>>('/login', data)
  methodInstance.meta = {
    authRole: null,
  }
  return methodInstance
}
export function fetchUpdateToken(data: any) {
  const method = request.Post<Service.ResponseResult<Api.Login.Info>>('/updateToken', data)
  method.meta = {
    authRole: 'refreshToken',
  }
  return method
}

// 直接返回静态路由，不需要后端接口
export function fetchUserRoutes(params: { id: number }) {
  // 动态导入静态路由
  return import('@/router/routes.static').then(module => ({
    isSuccess: true,
    errorType: null,
    code: 200,
    message: '成功',
    data: module.staticRoutes,
  })) as Promise<Service.ResponseResult<AppRoute.RowRoute[]>>
}
